﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SendDual.aspx.cs" Inherits="CRMWeb.Pages.SendDual" %>

<html>
<head id="Head1" runat="server">
    <title>Send SMS & EMAIL</title>
    <link rel="stylesheet" id="newtheme" type="text/css" href="/EasyUI/Themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="/EasyUI/Themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="/Css/CrmStyle.css" />
    <link rel="stylesheet" type="text/css" href="/Css/ProgressStyle.css" />
    <script type="text/javascript" src="/Scripts/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="/EasyUI/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/tiny_mce/tiny_mce.js"></script>

    <link href="../Css/uploadify.css" rel="stylesheet" />
    <script src="../Scripts/jquery.uploadify.js"></script>
    <script type="text/javascript" src="/Scripts/ProgressBar.js"></script>
    <script src="../Scripts/jquery.uploadifive.js"></script>
    <link href="../Css/uploadifive.css" rel="stylesheet" />
    <script type="text/javascript" src="/Scripts/flash_detect.js"></script>
    <script src="../Scripts/EmailSMSLog.js"></script>
    <style type="text/css">
        body {
            font: 13px Arial, Helvetica, Sans-serif;
        }

        #queue1 {
            border: 1px solid #E5E5E5;
            height: 40px;
            overflow: auto;
            margin-bottom: 10px;
            padding: 0 3px 3px;
            width: 190px;
        }

        #divSmsAccount {
            color: red;
            font-size: 13pt;
            font-weight: bold;
            width: auto;
        }
    </style>
    <style type="text/css">
        div.dimmers {
            visibility: hidden;
            position: absolute;
            left: 0px;
            top: 0px;
            font-family: verdana;
            font-weight: bold;
            padding: 40px;
            _background-image: none;
            _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale );
        }

        div.dimmings {
            font-family: Verdana, Arial, Helvetica, sans-serif;
            font-size: 11px;
            font-style: normal;
            background-color: #ffffff;
            position: absolute;
            z-index: 10000;
            visibility: hidden;
            border-style: solid;
            border-color: #999999;
            border-width: 1px;
        }

        .progress_tabs {
            font: 11px verdana;
            margin: 0;
            padding: 0;
            border: 2px #e1e1e1 solid;
            width: 120px;
        }
    </style>
</head>
<body onload="window.focus()">
    <form id="main" runat="server">
        <div id="pnlDual" title=" " class="easyui-panel" style="width: auto; height: auto;">
            <table id="dual" style="height: 20%">
                <tr>
                    <td colspan="2">
                        <div class="fitem">
                            <label style="width: 100px">Dual Template:</label>
                            <input class="easyui-combotree" id="cmbSU_emailTemp" runat="server" style="width: 500px;" name="EmailTemplate" />
                        </div>
                    </td>
                </tr>
                <tr>
                    <td style="text-align: left; width: 60%">
                        <div class="fitem" id="divSmsAccount">
                            <label style="width: 100px">SMS Account :</label>
                            <label id="lblFrom"></label>
                            <input id="hdnPassword" type="hidden" />
                        </div>
                        <div class="fitem">
                            <label style="width: 100px">From:</label>
                            <input class="easyui-combobox" id="cmbDual_from" runat="server" name="EmailId" style="width: 200px;" />
                            <input type="hidden" id="hdnfrompwdual" runat="server" />
                        </div>
                        <div class="fitem">
                            <label style="width: 100px">Send to:</label>
                            <select class="easyui-combogrid" id="cmbDual_to" style="width: 300px;" runat="server" name="FullName" data-options="  
                                panelWidth: 300,
                                multiple: true,
                                idField: 'MailID',  
                                textField: 'FullName',
                                editable:true,  
                                url: '/WebServices/SelectAppAndContacts.ashx?app_id=' + getQuerystring('app_id', '') + '&ContactID=' +getQuerystring('contact_id', ''),  
                                columns: [[  
                                    {field:'ck',checkbox:true},
                                    {field:'FullName',width:40},
                                    { field: 'MailID', width: 70 },    
                                ]],  
                                onSelect:getSelectionsForDualEmail, 
                                onUnselect:getUnselectForDualEmail,
                                fitColumns: true  
                                ">
                            </select>
                        </div>
                        <div class="fitem">
                            <label style="width: 100px">Email Address :</label>
                            <input id="txtSendDualTo" name="SendDual" type="text" class="easyui-validatebox" onchange="validateEmail($('#txtSendDualTo').val())" style="width: 300px" />
                            <span id="spnEmail" style="display: none; color: red; font-size: 14px;"><b>*</b> </span>
                        </div>
                        <div class="fitem">
                            <label style="width: 100px">Subject:</label>
                            <input id="txtSubjectDual" name="txt_subdual" type="text" class="easyui-validatebox" style="width: 300px" />
                        </div>
                    </td>
                    <td style="text-align: left; width: 40%">
                        <div class="fitem" style="margin-left: 10px">
                            <label style="width: 100px;">Attachment:</label>
                            <asp:FileUpload ID="FileUpload2" runat="server" Style="float: right" />
                            <input type="hidden" id="hdnDualAttachment" runat="server" />
                            <table id="attachedfilesDual" style="text-align: right"></table>
                        </div>

                        <div class="fitem" style="margin-left: 10px; margin-top: 10px">
                            <label style="width: 100px; text-align: left">Drag Here:</label>
                            <div id="queue1" style="float: right; width: 170px"></div>
                            <input id="file_upload_dual" name="file_upload_dual" type="file" style="display: none" multiple="true">

                            <input type="hidden" id="hdndualdragfile" runat="server" />
                        </div>
                    </td>
                    <td rowspan="2" style="text-align: center; width: 5%">
                        <div id="divProgressBars" class='dimmers' style="left: 218px; top: 223px;">
                            <table border='0' align='center' cellpadding='0' cellspacing='0' class='progress_tabs'>
                                <tr>
                                    <td ondblclick='void(0);' onmouseover='over=true;' onmouseout='over=false;'>&nbsp</td>
                                    <td>&nbsp</td>
                                    <td colspan='4'>&nbsp</td>
                                    <td>&nbsp</td>
                                </tr>
                                <tr>
                                    <td colspan='4'>&nbsp</td>
                                    <td>
                                        <img src='/Media/ajax-loader-blue.gif' alt='' /></td>
                                    <td colspan='4'>&nbsp</td>
                                    <td>Processing</td>
                                </tr>
                            </table>
                        </div>
                    </td>
                </tr>
            </table>

            <div class="fitem" style="padding: 5px;">
                <textarea id="txtmailmessage" name="MailDescription" class="easyui-validatebox" required="true" style="width: 100%; height: 400px"></textarea>
            </div>

            <div data-options="region:'center'" style="padding: 10px; height: 13%" class="smsbox">
                <label>Mobile No:</label>
                <select class="easyui-combogrid" id="cmbmobileno" style="width: 304px" runat="server" name="cmbmobileno" data-options="  
                    panelWidth: 304,  
                    multiple: true,
                    idField: 'Mobile',  
                    textField: 'Mobile',
                    editable:true,  
                    url: '/WebServices/SMSHandler.ashx?method=getAllMobileNo&ID=' + getQueryParameter()+ '&isAppID='+ getQuerystring('isAppID',''),
                    columns: [[  
                    {field:'ck',checkbox:true},
                    {field:'FirstName',width:80},      
                    ]], 
                        onSelect:getSelections, 
                        onUnselect:getUnselected,
                    fitColumns: true  
                    ">
                </select>
                <span id="spnInvalidNumber" style="display: none; width: auto">
                    <label id="lblAlert" style="color: red; width: auto">Please enter valid Mobile number ! </label>
                </span>
                <textarea id="txtsmsdescriptiondual" name="SMSDescription" class="easyui-validatebox" onkeydown="limitText()" onkeyup="limitText();" onchange="chkValue()" data-options="required:true" style="font-family: Arial; width: 100%; height: 73%"></textarea>
            </div>
            <table id="tblbottom" style="width: 100%; height: 4%">
                <tr>
                    <td style="text-align: left; width: 50%">
                        <span id="divLeftCharacters">You have
                            <label id="lblCountDowns">159</label>
                            characters left.
                        </span>
                        <span id="divMaxLimits" style="display: none; color: red;">This SMS will be charged  twice as its over 159 characters
                        </span>
                        <span id="spnerror" style="display: none">
                            <label id="lblerrordual" style="font-size: 14px; font-weight: bold; padding-right: 51px; color: red;" runat="server"></label>
                        </span>
                    </td>
                    <td style="text-align: right; width: 50%; padding-bottom: 20px;">
                        <a id="lnkSend" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" disabled="true" onclick="sendEmailAndSms();">Send</a>
                    </td>
                </tr>

            </table>
            <asp:ScriptManager ID="sm1" runat="server" EnablePageMethods="true"></asp:ScriptManager>
            <input type="hidden" runat="server" id="hdnDualOpr" />
            <input type="hidden" id="hdnNodeValInDualPage" runat="server" />
            <input type="hidden" id="hdnCategoryID" />
        </div>
    </form>
    <script type="text/javascript">


        $('#cmbSU_emailTemp').combotree({
            url: '/WebServices/DualTemplate.ashx?method=GetDualRoleTemplate&Company=' + getQuerystring('company', ''),
            valueField: 'DualTemplateID',
            textField: 'DualTemplate',
            multiple: false,
            onSelect: selectDualTemplate,
        });


        function selectDualTemplate(node) {

            var currentTemplateId = node.id;
            if (currentTemplateId == -1) {
                $.messager.alert('Morgan CRM', 'Please select Template Item ... !', 'warning');
            }
            else {
                $.ajax({
                    url: "/WebServices/DualTemplate.ashx?method=GetDualTemplateContentById",
                    contentType: "application/json; charset=utf-8",
                    data: { DualTemplateId: currentTemplateId },
                    success: function (data) {
                        $.each(eval(data.replace(/[\r\n]/, '')), function (i, result) {
                            $('#txtSubjectDual').val(result.DualSubject);
                            $('#hdnCategoryID').val(result.CategoryId);
                            if (getQuerystring('contact_id', '') != '') {
                                showContactDataSd(result.Emailformat);
                                showContactDataSms(result.Smsformat);
                            }
                            else if (getQuerystring('app_id', '') != '') {
                                showApplicationDataSd(result.Emailformat);
                                showApplicationDataSms(result.Smsformat);
                            }
                            else {
                                $('#txtsmsdescriptiondual').val(result.Smsformat);
                                if (result.Smsformat != "") {
                                    $('#txtsmsdescriptiondual').validatebox({
                                        required: false,

                                    });
                                }
                                tinymce.get('txtmailmessage').setContent(decodeURIComponent(result.Emailformat));
                            }
                            setTimeout(function () {
                                limitText();
                            }, 500);
                        });
                    },
                    error: function () {
                        alert("Error while getting template.");
                    }
                });
            }
        }

        $(document).ready(function () {
            OperatorId = document.getElementById('hdnNodeValInDualPage').value;
            $('#newtheme').attr('href', '/EasyUI/Themes/' + getQuerystring('Theme', 'Default') + '/easyui.css');
            $("#pnlDual").panel('setTitle', 'Send Dual ');
            FetchDualName();
            $.ajax({
                url: '/WebServices/SMSAccountSetting.ashx?method=SelectFromSMSID',
                data: { Company: getQuerystring('company', '') },
                success: function (data) {
                    if (data == '0') {
                        $.messager.alert('Morgan CRM', 'No SMS Account information avilable', 'warning');
                    }
                    else if (data == 'Error')
                        $.messager.alert('Morgan CRM', 'Error occured while getting SMS Account Information', 'error');
                    else {
                        $.each(eval(data.replace(/[\r\n]/, '')), function (i, rec) {
                            $('#hdnPassword').val(rec.Password);
                            $('#lblFrom').html(rec.SMSAccount);
                            $('#lnkSend').linkbutton('enable');
                        });
                    }
                }
            });
            $('#txtSendDualTo').val(getQuerystring('email', ''));
            $('#cmbDual_to').combogrid('setValue', getQuerystring('email', ''));
            $('#cmbmobileno').combogrid('setValue', getQuerystring('mobileno', ''));

            $('#pnlDual').panel('resize', {
                width: window.innerWidth,
                height: window.innerHeight
            });
            $('#cmbDual_to').combobox('textbox').bind('click', function () {
                $('#cmbDual_to').combobox('showPanel');
            });
            $('#cmbSU_emailTemp').combobox('textbox').bind('click', function () {
                $('#cmbSU_emailTemp').combobox('showPanel');
            });
            $('#cmbmobileno').combobox('textbox').bind('click', function () {
                $('#cmbmobileno').combobox('showPanel');
            });
            //$('#txtSendDualTo').val(getQuerystring('email', ''));
            //$("#cmbDual_to").combogrid('setValue', getQuerystring('email', ''));
            //$('#cmbmobileno').combogrid('setValue', getQuerystring('mobileno', ''));

            $('#cmbSU_emailTemp').combotree({
                onClick: function (node) {
                    if (!$('#cmbSU_emailTemp').tree('isLeaf', node.target)) {
                        $('#cmbSU_emailTemp').combotree('setValues', '');
                        var t = $('#cmbSU_emailTemp').combotree('tree');
                        t.tree('toggle', node.target);
                        var p = $('#cmbSU_emailTemp').combotree('panel');
                        p.panel('open');
                    }
                }
            });

            $('#cmbDual_from').combobox({
                url: '/WebServices/EmailTemplate.ashx?method=SelectAllEmailId&Company=' + getQuerystring('company', ''),
                valueField: 'emailaccount',
                textField: 'emailaccount',
                multiple: false,
                editable: false,
                selected: true,
                onSelect: getEmailAccountPassword,
                onLoadSuccess: function (data) {
                    $(this).combobox('select', data[0]['emailaccount']);
                },

            });
            function getEmailAccountPassword(rec) {
                //  alert(rec.Password);
                $('#hdnfrompwdual').val(rec.Password);
            }
            function getCookie(key) {
                var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
                return keyValue ? keyValue[2] : '';
            }

            $('#txtSendDualTo').val(getQuerystring('email', ''));
            $("#cmbDual_to").combogrid('setValue', getQuerystring('email', ''));
            $('#FileUpload2').css('float', 'right');
        });


        function getSelectionsForDualEmail() {
            var ss = [];
            var r = $('#cmbDual_to').combogrid('grid');
            var rows = r.datagrid('getSelections');
            for (var i = 0; i < rows.length; i++) {
                var row = rows[i];
                ss.push(row.MailID);
            }
            $("#txtSendDualTo").val(ss.join(','));
        }

        function getUnselectForDualEmail() {
            $("#txtSendDualTo").val('');
            getSelectionsForDualEmail();
        }

        var isProgressBarFlags = true;
        function DisplayProgessBarEvents() {
            var ls, ts;
            ls = screen.width / 2;
            ts = screen.height / 3;
            ActiveDivPUids = 'divProgressBars';
            var DivContents = document.createElement('div');
            var objDivs = document.getElementById('divProgressBars');
            objDivs.className = 'dimmings';
            objDivs.style.visibility = "visible";
            isProgressBarFlags = true;
        }
        window.onresize = function () {
            $('#pnlDual').panel('resize', {
                width: window.innerWidth,
                height: window.innerHeight
            });
        }
        function getQuerystring(key, defaultValue) {
            if (defaultValue == null) defaultValue = "";
            key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
            var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
            var qs = regex.exec(window.location.href);

            if (qs == null || qs == 'null')
                return defaultValue;
            else {
                if (qs[1] == 'null' || qs[1] == null)
                    return defaultValue;
                else
                    return qs[1];
            }
        }

        function FetchDualName() {
            $.ajax({
                url: "/WebServices/SMSHandler.ashx?method=getEmailwithFullName",
                data: { 'app_id': getQuerystring('app_id', ''), 'ContactID': getQuerystring('contact_id', '') },
                success: function (data) {
                    $.each(eval(data.replace(/[\r\n]/, '')), function (i, rec) {
                        $("#pnlDual").panel('setTitle', 'Send Dual  ' + rec.FullName);
                        $('#cmbDual_to').combogrid('setValue', rec.Email);
                        $('#txtSendDualTo').val(rec.Email);
                        $('#cmbmobileno').combogrid('setValue', rec.Mobile);
                    });
                }
            });
        }

        function HideProgressBarEvents() {
            var objPUs = document.getElementById('divProgressBars');
            $(document).ready(function () {
                $("#divProgressBars").fadeOut(500, function () {
                    isProgressBarFlags = false;
                });
            });
        }
        function GetProgressBar_PUs(divId) {
            var HtmlContents = "<div id='" + divId + "' class='dimmers'  >" +
            "<table border='0' align='center' cellpadding='0' cellspacing='0' class='progress_tabs'>" +
            "<tr><td ondblclick='void(0);' onmouseover='over=true;' onmouseout='over=false;'>&nbsp</td>" +
            "<td>&nbsp</td><td colspan='4'>&nbsp</td><td>&nbsp</td></tr><tr><td colspan='4'>&nbsp</td>" +
            "<td><img src='/Media/ajax-loader-blue.gif' alt=''/></td><td colspan='4'>&nbsp</td><td>Processing</td>" +
            "</tr><tr><td>&nbsp</td><td>&nbsp</td><td>&nbsp</td></tr></table></div>";
            return HtmlContents;
        }
    </script>
    <script type="text/javascript">
        tinyMCE.init({
            mode: "exact",
            elements: "txtmailmessage",
            theme: "advanced",
            plugins: "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
            theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2: "bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,help,code,|,forecolor,backcolor",
            setup: function (ed) {
                ed.onInit.add(function (ed) {
                    ed.getDoc().body.style.fontSize = '13pt';
                });
            }
        });


        //Attachments:
        $(window).load(
           $(function () {
               $("#FileUpload2").uploadify({
                   'swf': '../Media/uploadify.swf',
                   'uploader': '/WebServices/AttachmentUpload.ashx',
                   'cancelImg': '../Media/cancel.png',
                   'buttonText': 'Attach Files',
                   'fileSizeLimit': '11MB',
                   'fileDesc': 'Image Files',
                   'fileTypeExts': '*.jpg;*.jpeg;*.gif;*.png;*.txt;*.pdf',
                   'multi': true,
                   'auto': true,
                   'onUploadComplete': function (file) {
                       var attchVal = fileName;
                       $("#hdnDualAttachment").val(attchVal);
                   }

               });
           })
);

        //Drag and drop
        $(function () {
            $('#file_upload_dual').uploadifive({
                'auto': true,
                'queueID': 'queue1',
                'fileSizeLimit': '11MB',
                'uploadScript': '/WebServices/Upload.ashx',
                'onUploadComplete': function (file, data) {

                    $("#hdndualdragfile").val(data);
                }
            });
        });


    </script>
    <script type="text/javascript">
        //Get NodeId:
        var OperatorId = '';


        function validateEmail(elementValue) {
            elementValue = elementValue.replace(/,,*/g, ',').replace(/,$/, '').replace(/^,/, '');
            var flag = false;
            var emails = [];
            emails = elementValue.split(',');

            for (i = 0; i < emails.length; i++) {
                var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
                if (emailPattern.test(emails[i]) == true)
                    flag = true;
                else {
                    flag = false;
                    break;
                }
            }

            if (flag == true) {
                $('#spnEmail').hide();
                return true;
            } else {
                $('#spnEmail').show();
                $('#txtSendDualTo').focus();
                return false;
            }

        }

        function IsValidate() {
            var flag = true;
            if ($('#cmbSU_emailTemp').combobox('getValue') == '') {
                $.messager.alert('Morgan CRM', 'Select Dual Template ', 'info');
                return flag = false;
            }
            if ($('#cmbDual_from').combobox('getValue') == '') {
                $.messager.alert('Morgan CRM', 'Select From ', 'info');
                return flag = false;
            }

            var bodyContent = tinyMCE.get('txtmailmessage').getContent();
            bodyContent = $(bodyContent).text().trim();

            if (bodyContent.length == 0) {
                $.messager.alert('Morgan CRM', 'E-Mail content is Empty ! ', 'info');
                return false;
            }

            var Msgtext = $('#txtsmsdescriptiondual').val().trim();
            if (Msgtext.length == 0) {
                $.messager.alert('Morgan CRM', 'SMS content is Empty ! ', 'info');
                return false;
            }

            if (!validateEmail($('#txtSendDualTo').val())) {
                $.messager.alert('Morgan CRM', '<span style="color:red">Enter Vaild Email Address </span>', 'info');
                return;
            }
            if ($('#txtSubjectDual').val() == '') {
                $.messager.alert('Morgan CRM', 'Enter Subject ', 'info');
                return flag = false;
            }


            return flag;
        }


        //Send Email Function
        function sendEmailAndSms() {

            if (IsValidate()) {
                var nos = $('#cmbmobileno').combobox('getText');
                nos = nos.replace(/,,*/g, ',');
                nos = nos.replace(/^,/, '');
                nos = nos.replace(/$,/, '');
                $.ajax({
                    url: '/WebServices/SMSHandler.ashx?method=CheckMobileNos',
                    data: { 'MobileNo': nos },
                    success: function (response) {
                        if (response == "1") {
                            $('#spnInvalidNumber').hide();
                            fn_sendDual();
                        }
                        else if (response == "0") {
                            $('#spnInvalidNumber').show();
                        }
                    }
                });

            }
        }

        function fn_sendDual() {
            //Wade changed following coding 20140204
            var password = $('#hdnfrompwdual').val();
            //var password = $("#cmbDual_from").combobox('getValue');
            if (password == null) {
                alert('Oops your password is not found!');
                HideProgressBarEvent();
            }
            else {
                DisplayProgessBarEvents();
                var fromName = $("#cmbDual_from").combobox('getText');
                var toName = $("#txtSendDualTo").val().replace(/,,*/g, ',').replace(/,$/, '').replace(/^,/, '');;
                var attachmentFile = $("#hdnDualAttachment").val();
                var attachmentsDrag = $("#hdndualdragfile").val();
                var subject = $("#txtSubjectDual").val();
                var bodyContent = tinyMCE.get('txtmailmessage').getContent({ format: 'raw' });
                $.ajax({
                    type: "Post",
                    url: "/WebServices/SendEmailToUsers.ashx",
                    data: { fromName: fromName, password: password, toName: toName, attachmentFile: attachmentFile, attachmentsDrag: attachmentsDrag, subject: subject, bodyContent: bodyContent },
                    success: function (data) {
                        if (data == "0")
                            writeLog(bodyContent, "Email", "Failed", document.getElementById('hdnDualOpr').value, $('#hdnCategoryID').val());
                        else
                            writeLog(bodyContent, "Email", "Success", document.getElementById('hdnDualOpr').value, $('#hdnCategoryID').val());


                        var result = isSMSValidDual();
                        if (result == "Error")
                            writeLog($('#txtsmsdescriptiondual').val(), "SMS", "Failed", document.getElementById('hdnDualOpr').value, $('#hdnCategoryID').val());
                        else
                            writeLog($('#txtsmsdescriptiondual').val(), "SMS", "Success", document.getElementById('hdnDualOpr').value, $('#hdnCategoryID').val());

                        document.getElementById("attachedfilesDual").innerHTML = '';
                        document.getElementById("queue1").innerHTML = '';

                        HideProgressBarEvents();

                        //To update history table
                        UpdateHistory(data);
                    }
                });
            }
        }
        function getQueryParameter() {
            var queryString = window.location.search.substring(1);
            var queryparam = queryString.split("=");
            var firstParameter = queryparam[1].split("&");
            return firstParameter[0];
        }
        var contactno;
        var hdnTextFirstName;
        var fsNames;
        function getSelections() {
            var ss = [];
            var r = $('#cmbmobileno').combogrid('grid');
            var rows = r.datagrid('getSelections');

            for (var i = 0; i < rows.length; i++) {
                var row = rows[i];
                ss.push(row.Mobile);
                fsNames = (row.FirstName);
            }
            contactno = ss.join(';').replace(',', ';');
            contactno = $("#cmbmobileno").combogrid('getText').replace(/,/g, ';');

        }
        var Name;

        function getUnselected() {
            contactno = '';
            hdnTextFirstName = '';
        }
        function isSMSValidDual() {
            var response = '';
            if ($('#cmbmobileno').combobox('getText') == '' || $('#txtsmsdescriptiondual').val() == '') {
                HideProgressBarEvents();
                $('#spnerror').show();
                $('#lblerrordual').html("SMS Sending Failed!");
                return false;
            }
            var nos = $('#cmbmobileno').combobox('getText');
            nos = nos.replace(/,,*/g, ',');
            nos = nos.replace(/^,/, '');
            nos = nos.replace(/$,/, '');
            $.ajax({
                url: '/WebServices/SMSHandler.ashx?method=SendSMS',
                data: { MobileNo: nos, Message: $('#txtsmsdescriptiondual').val(), compnayAccount: $('#lblFrom').text(), smsPassword: $('#hdnPassword').val() },
                success: function (result) {
                    response = result;
                }
            });
            return response;
        }

        function onSuccess() {
            $("#txtSendDualTo").val('');
            $('#cmbmobileno').combobox('setText', '');
            $('#txtsmsdescriptiondual').val('');
            $("#txtSubjectDual").val('');
            tinymce.get('txtmailmessage').setContent('');
            window.opener.location.reload(true);
            window.close();
        }


        function UpdateHistory(attachmentlist) {
            var ContactID = getQuerystring('contact_id', 0);
            var AppID = getQuerystring("app_id", 0);
            var currentDate = new Date();

            var HistoryDate = (currentDate.getMonth() + 1) + "/" + currentDate.getDate() + "/" + currentDate.getFullYear();
            var currentTime = new Date();
            var HistoryTime = currentTime.getHours() + ':' + currentTime.getMinutes() + ':' + currentTime.getSeconds();
            var Action = 'Email & SMS Sent';
            var Operator = document.getElementById('hdnDualOpr').value;
            var toName = $("#txtSendDualTo").val().replace(/,,*/g, ',').replace(/,$/, '').replace(/^,/, '');
            var emailTxtVal = tinyMCE.get('txtmailmessage').getContent({ format: 'raw' });
            var smsTxtVal = $('#txtsmsdescriptiondual').val();
            var ColVals = '';


            if (attachmentlist.length > 0) {
                attachmentlist = attachmentlist.replace(/,$/, '');
                ColVals = 'To: ' + toName + '</br> <span style=\"color:red;font-weight:bold\">Attachments:-  ' + attachmentlist + ' </span> </br> Email Content :-' + emailTxtVal + '</br>' +
                           'To: ' + fsNames + '</br>' + 'Mobile No. : ' + $('#cmbmobileno').combobox('getText') + '<br/></br>SMS Content : ' + smsTxtVal;
            }
            else
                ColVals = 'To: ' + toName + '</br> Email Content :-' + emailTxtVal + '</br>' + 'To: ' + fsNames + '</br>' + 'Mobile No. : ' + $('#cmbmobileno').combobox('getText') + '<br/></br>SMS Content : ' + smsTxtVal;


            var desc = encodeURIComponent(ColVals);

            if (AppID > 0) {
                PageMethods.saveNewHistory('Application', '0', HistoryDate, HistoryTime, Action, Operator, desc, AppID);
                setTimeout(function () {
                    onSuccess();
                }, 100);
            }
            else if (ContactID > 0) {
                PageMethods.saveNewHistory('Contact', ContactID, HistoryDate, HistoryTime, Action, Operator, desc, '0');
                setTimeout(function () {
                    onSuccess();
                }, 100);
            }
            else
                onSuccess();
        }


        function showContactDataSd(EMAILTemplateFormat) {
            $.ajax({
                url: "/WebServices/ApplicationContact.ashx?method=ApplicationContactSelect",
                contentType: "application/json; charset=utf-8",
                data: { 'ContactID': getQuerystring('contact_id', '') },
                success: function (data) {
                    $.each(eval(data.replace(/[\r\n]/, '')), function (i, rec) {
                        var decodeTemp = decodeURIComponent(EMAILTemplateFormat);

                        //ClientFileds
                        decodeTemp = decodeTemp.replace('%ContactID (Client)%', rec.ContactID);
                        decodeTemp = decodeTemp.replace('%FirstName (Client)%', rec.FirstName);
                        decodeTemp = decodeTemp.replace('%MiddleName (Client)%', rec.MiddleName);
                        decodeTemp = decodeTemp.replace('%SurName (Client)%', rec.SurName);
                        decodeTemp = decodeTemp.replace('%Title (Client)%', rec.Title);
                        decodeTemp = decodeTemp.replace('%Mobile (Client)%', rec.Mobile);
                        decodeTemp = decodeTemp.replace('%HomePhone (Client)%', rec.HomePhone);
                        decodeTemp = decodeTemp.replace('%Email (Client)%', rec.Email);
                        decodeTemp = decodeTemp.replace('%DriverLicense (Client)%', rec.DriverLicense);
                        decodeTemp = decodeTemp.replace('%Citizenship (Client)%', rec.Citizenship);
                        decodeTemp = decodeTemp.replace('%DateBirth (Client)%', rec.DateBirth);
                        decodeTemp = decodeTemp.replace('%Street (Client)%', rec.Street);
                        decodeTemp = decodeTemp.replace('%Suburb (Client)%', rec.Suburb);
                        decodeTemp = decodeTemp.replace('%State (Client)%', rec.State);
                        decodeTemp = decodeTemp.replace('%PostCode (Client)%', rec.PostCode);
                        decodeTemp = decodeTemp.replace('%ResidencePeriod (Client)%', rec.ResidencePeriod);
                        decodeTemp = decodeTemp.replace('%ResidenceLength (Client)%', rec.ResidenceLength);
                        decodeTemp = decodeTemp.replace('%Dependant (Client)%', rec.Dependant);
                        decodeTemp = decodeTemp.replace('%app_ResidentialStatus (Client)%', rec.app_ResidentialStatus);
                        decodeTemp = decodeTemp.replace('%app_number (Client)%', rec.app_number);
                        decodeTemp = decodeTemp.replace('%app_id (Client)%', rec.app_id);
                        decodeTemp = decodeTemp.replace('%NumberFromAppinfo (Client)%', rec.NumberFromAppinfo);
                        decodeTemp = decodeTemp.replace('%Memo (Client)%', rec.Memo);
                        decodeTemp = decodeTemp.replace('%CreateDate (Client)%', rec.CreateDate);
                        decodeTemp = decodeTemp.replace('%EditDate (Client)%', rec.EditDate);
                        decodeTemp = decodeTemp.replace('%DupwithContact (Client)%', rec.DupwithContact);
                        decodeTemp = decodeTemp.replace('%deletedFlag (Client)%', rec.deletedFlag);
                        decodeTemp = decodeTemp.replace('%Role (Client)%', rec.Role);
                        decodeTemp = decodeTemp.replace('%Relationship (Client)%', rec.Relationship);
                        decodeTemp = decodeTemp.replace('%WorkPhone (Client)%', rec.WorkPhone);
                        decodeTemp = decodeTemp.replace('%FaxNumber (Client)%', rec.FaxNumber);
                        decodeTemp = decodeTemp.replace('%secondEmailAddress (Client)%', rec.secondEmailAddress);
                        decodeTemp = decodeTemp.replace('%PostalAddress (Client)%', rec.PostalAddress);
                        decodeTemp = decodeTemp.replace('%IncomeType (Client)%', rec.IncomeType);
                        decodeTemp = decodeTemp.replace('%SelfEmpTypeofEntity (Client)%', rec.SelfEmpTypeofEntity);
                        decodeTemp = decodeTemp.replace('%SelfEmpBusinessName (Client)%', rec.SelfEmpBusinessName);
                        decodeTemp = decodeTemp.replace('%SelfEmpABN (Client)%', rec.SelfEmpABN);
                        decodeTemp = decodeTemp.replace('%SelfEmpNatureofBusiness (Client)%', rec.SelfEmpNatureofBusiness);
                        decodeTemp = decodeTemp.replace('%SelfEmpPhone (Client)%', rec.SelfEmpPhone);
                        decodeTemp = decodeTemp.replace('%SelfEmpAddress (Client)%', rec.SelfEmpAddress);
                        decodeTemp = decodeTemp.replace('%KinsName (Client)%', rec.KinsName);
                        decodeTemp = decodeTemp.replace('%KinsRelationship (Client)%', rec.KinsRelationship);
                        decodeTemp = decodeTemp.replace('%KinsContactNumber (Client)%', rec.KinsContactNumber);
                        decodeTemp = decodeTemp.replace('%Notes (Client)%', rec.Notes);
                        decodeTemp = decodeTemp.replace('%EmpEmployer (Client)%', rec.EmpEmployer);
                        decodeTemp = decodeTemp.replace('%EmpOccupation (Client)%', rec.EmpOccupation);
                        decodeTemp = decodeTemp.replace('%EmpJobPosition (Client)%', rec.EmpJobPosition);
                        decodeTemp = decodeTemp.replace('%EmpEmployerPhone (Client)%', rec.EmpEmployerPhone);
                        decodeTemp = decodeTemp.replace('%EmpContactPerson (Client)%', rec.EmpContactPerson);
                        decodeTemp = decodeTemp.replace('%EmpWorkAddress (Client)%', rec.EmpWorkAddress);
                        decodeTemp = decodeTemp.replace('%comesfrom (Client)%', rec.comesfrom);
                        //Loan Fileds
                        decodeTemp = decodeTemp.replace('%LoanID (Loan)%', rec.LoanID);
                        decodeTemp = decodeTemp.replace('%LoanNumber (Loan)%', rec.LoanNumber);
                        decodeTemp = decodeTemp.replace('%PaymentPeriod (Loan)%', rec.PaymentPeriod);
                        decodeTemp = decodeTemp.replace('%DrawDownDate (Loan)%', rec.DrawDownDate);
                        decodeTemp = decodeTemp.replace('%LoanStatusID (Loan)%', rec.LoanStatusID);
                        decodeTemp = decodeTemp.replace('%LoanTerm (Loan)%', rec.LoanTerm);
                        decodeTemp = decodeTemp.replace('%FirstPaymentDue (Loan)%', rec.FirstPaymentDue);
                        decodeTemp = decodeTemp.replace('%LowerRate (Loan)%', rec.LowerRate);
                        decodeTemp = decodeTemp.replace('%HigherRate (Loan)%', rec.HigherRate);
                        decodeTemp = decodeTemp.replace('%InterestMethod (Loan)%', rec.InterestMethod);
                        decodeTemp = decodeTemp.replace('%app_id (Loan)%', rec.app_id);
                        decodeTemp = decodeTemp.replace('%Lender (Loan)%', rec.Lender);
                        decodeTemp = decodeTemp.replace('%Product (Loan)%', rec.Product);
                        decodeTemp = decodeTemp.replace('%Type (Loan)%', rec.Type);
                        decodeTemp = decodeTemp.replace('%Purpose (Loan)%', rec.Purpose);
                        decodeTemp = decodeTemp.replace('%LoanAmount (Loan)%', rec.LoanAmount);
                        decodeTemp = decodeTemp.replace('%DishonorFee (Loan)%', rec.DishonorFee);
                        decodeTemp = decodeTemp.replace('%Memo (Loan)%', rec.Memo);
                        decodeTemp = decodeTemp.replace('%NewDDRDate (Loan)%', rec.NewDDRDate);
                        decodeTemp = decodeTemp.replace('%BankAccDate (Loan)%', rec.BankAccDate);
                        decodeTemp = decodeTemp.replace('%PaymentSchDate (Loan)%', rec.PaymentSchDate);
                        decodeTemp = decodeTemp.replace('%EffectiveDate (Loan)%', rec.EffectiveDate);
                        decodeTemp = decodeTemp.replace('%DefaultNotice (Loan)%', rec.DefaultNotice);
                        decodeTemp = decodeTemp.replace('%DoubleChecked (Loan)%', rec.DoubleChecked);
                        decodeTemp = decodeTemp.replace('%CreateDate (Loan)%', rec.CreateDate);
                        decodeTemp = decodeTemp.replace('%EditDate (Loan)%', rec.EditDate);
                        decodeTemp = decodeTemp.replace('%LastResult (Loan)%', rec.LastResult);
                        decodeTemp = decodeTemp.replace('%EzidebitRefNo (Loan)%', rec.EzidebitRefNo);
                        decodeTemp = decodeTemp.replace('%OperatorName%', document.getElementById('hdnDualOpr').value);

                        tinymce.get('txtmailmessage').setContent(decodeTemp);
                    });
                }
            });
        }

        var FsName = [];
        var MidName = [];
        var LastName = [];
        var strFsName;
        var strMidName;
        var strLsName;
        function showApplicationDataSd(EMAILTemplateFormat) {
            $.ajax({
                url: "/WebServices/ApplicationProfileDataSelect.ashx",
                contentType: "application/json; charset=utf-8",
                data: { 'app_id': getQuerystring('app_id', ''), 'OperatorId': OperatorId },
                success: function (data) {
                    $.each(eval(data.replace(/[\r\n]/, '')), function (i, rec) {

                        var decodeTemp = decodeURIComponent(EMAILTemplateFormat);

                        //ApplicationFileds
                        decodeTemp = decodeTemp.replace('%app_id (Application)%', rec.app_id);
                        decodeTemp = decodeTemp.replace('%deletedFlag (Application)%', rec.deletedFlag);
                        decodeTemp = decodeTemp.replace('%app_result (Application)%', rec.app_result);
                        decodeTemp = decodeTemp.replace('%ResultID (Application)%', rec.ResultID);
                        decodeTemp = decodeTemp.replace('%LoadNo (Application)%', rec.LoadNo);
                        decodeTemp = decodeTemp.replace('%Folder (Application)%', rec.Folder);
                        decodeTemp = decodeTemp.replace('%AwaitDocs (Application)%', rec.AwaitDocs);
                        decodeTemp = decodeTemp.replace('%NoInApplication (Application)%', rec.NoInApplication);
                        decodeTemp = decodeTemp.replace('%OfferedAmount (Application)%', rec.OfferedAmount);
                        decodeTemp = decodeTemp.replace('%DesiredAmount (Application)%', rec.DesiredAmount);
                        decodeTemp = decodeTemp.replace('%amountMoto (Application)%', rec.amountMoto);
                        decodeTemp = decodeTemp.replace('%amoutProperties (Application)%', rec.amoutProperties);
                        decodeTemp = decodeTemp.replace('%TextAwaitDoc (Application)%', rec.TextAwaitDoc);
                        decodeTemp = decodeTemp.replace('%PurposeSummary (Application)%', rec.PurposeSummary);
                        // decodeTemp = decodeTemp.replace('%Unsubscribe_Ad (Application)%', rec.Unsubscribe_Ad);
                        decodeTemp = decodeTemp.replace('%Memo (Application)%', rec.Memo);
                        decodeTemp = decodeTemp.replace('%LenderID (Application)%', rec.LenderID);
                        decodeTemp = decodeTemp.replace('%OutSrcLenderVal (Application)%', rec.OutSrcLenderVal);
                        decodeTemp = decodeTemp.replace('%ReferrerID (Application)%', rec.ReferrerID);
                        decodeTemp = decodeTemp.replace('%ReferrerVal (Application)%', rec.ReferrerVal);
                        decodeTemp = decodeTemp.replace('%CreatedDate (Application)%', rec.CreatedDate);
                        decodeTemp = decodeTemp.replace('%EditDate (Application)%', rec.EditDate);
                        decodeTemp = decodeTemp.replace('%comesfrom (Application)%', rec.comesfrom);
                        decodeTemp = decodeTemp.replace('%securities (Application)%', rec.securities);
                        //ClientFileds
                        decodeTemp = decodeTemp.replace('%ContactID (Client)%', rec.ContactID);

                        //First applicant name:
                        FsName.push(rec.FirstName);
                        strFsName = FsName[0];
                        decodeTemp = decodeTemp.replace('%FirstName (Client)%', strFsName);


                        MidName.push(rec.MiddleName);
                        strMidName = MidName[0];
                        decodeTemp = decodeTemp.replace('%MiddleName (Client)%', strMidName);

                        LastName.push(rec.SurName);
                        strLsName = LastName[0];
                        decodeTemp = decodeTemp.replace('%SurName (Client)%', strLsName);

                        decodeTemp = decodeTemp.replace('%Title (Client)%', rec.Title);
                        decodeTemp = decodeTemp.replace('%Mobile (Client)%', rec.Mobile);
                        decodeTemp = decodeTemp.replace('%HomePhone (Client)%', rec.HomePhone);
                        decodeTemp = decodeTemp.replace('%Email (Client)%', rec.Email);
                        decodeTemp = decodeTemp.replace('%DriverLicense (Client)%', rec.DriverLicense);
                        decodeTemp = decodeTemp.replace('%Citizenship (Client)%', rec.Citizenship);
                        decodeTemp = decodeTemp.replace('%DateBirth (Client)%', rec.DateBirth);
                        decodeTemp = decodeTemp.replace('%Street (Client)%', rec.Street);
                        decodeTemp = decodeTemp.replace('%Suburb (Client)%', rec.Suburb);
                        decodeTemp = decodeTemp.replace('%State (Client)%', rec.State);
                        decodeTemp = decodeTemp.replace('%PostCode (Client)%', rec.PostCode);
                        decodeTemp = decodeTemp.replace('%ResidencePeriod (Client)%', rec.ResidencePeriod);
                        decodeTemp = decodeTemp.replace('%ResidenceLength (Client)%', rec.ResidenceLength);
                        decodeTemp = decodeTemp.replace('%Unsubscribe_Ad (Client)%', rec.Unsubscribe_Ad);
                        decodeTemp = decodeTemp.replace('%Dependant (Client)%', rec.Dependant);
                        decodeTemp = decodeTemp.replace('%app_ResidentialStatus (Client)%', rec.app_ResidentialStatus);
                        decodeTemp = decodeTemp.replace('%app_number (Client)%', rec.app_number);
                        decodeTemp = decodeTemp.replace('%app_id (Client)%', rec.app_id);
                        decodeTemp = decodeTemp.replace('%NumberFromAppinfo (Client)%', rec.NumberFromAppinfo);
                        decodeTemp = decodeTemp.replace('%Memo (Client)%', rec.Memo);
                        decodeTemp = decodeTemp.replace('%CreateDate (Client)%', rec.CreateDate);
                        decodeTemp = decodeTemp.replace('%EditDate (Client)%', rec.EditDate);
                        decodeTemp = decodeTemp.replace('%DupwithContact (Client)%', rec.DupwithContact);
                        decodeTemp = decodeTemp.replace('%deletedFlag (Client)%', rec.deletedFlag);
                        decodeTemp = decodeTemp.replace('%Role (Client)%', rec.Role);
                        decodeTemp = decodeTemp.replace('%Relationship (Client)%', rec.Relationship);
                        decodeTemp = decodeTemp.replace('%WorkPhone (Client)%', rec.WorkPhone);
                        decodeTemp = decodeTemp.replace('%FaxNumber (Client)%', rec.FaxNumber);
                        decodeTemp = decodeTemp.replace('%secondEmailAddress (Client)%', rec.secondEmailAddress);
                        decodeTemp = decodeTemp.replace('%PostalAddress (Client)%', rec.PostalAddress);
                        decodeTemp = decodeTemp.replace('%IncomeType (Client)%', rec.IncomeType);
                        decodeTemp = decodeTemp.replace('%SelfEmpTypeofEntity (Client)%', rec.SelfEmpTypeofEntity);
                        decodeTemp = decodeTemp.replace('%SelfEmpBusinessName (Client)%', rec.SelfEmpBusinessName);
                        decodeTemp = decodeTemp.replace('%SelfEmpABN (Client)%', rec.SelfEmpABN);
                        decodeTemp = decodeTemp.replace('%SelfEmpNatureofBusiness (Client)%', rec.SelfEmpNatureofBusiness);
                        decodeTemp = decodeTemp.replace('%SelfEmpPhone (Client)%', rec.SelfEmpPhone);
                        decodeTemp = decodeTemp.replace('%SelfEmpAddress (Client)%', rec.SelfEmpAddress);
                        decodeTemp = decodeTemp.replace('%KinsName (Client)%', rec.KinsName);
                        decodeTemp = decodeTemp.replace('%KinsRelationship (Client)%', rec.KinsRelationship);
                        decodeTemp = decodeTemp.replace('%KinsContactNumber (Client)%', rec.KinsContactNumber);
                        decodeTemp = decodeTemp.replace('%Notes (Client)%', rec.Notes);
                        decodeTemp = decodeTemp.replace('%EmpEmployer (Client)%', rec.EmpEmployer);
                        decodeTemp = decodeTemp.replace('%EmpOccupation (Client)%', rec.EmpOccupation);
                        decodeTemp = decodeTemp.replace('%EmpJobPosition (Client)%', rec.EmpJobPosition);
                        decodeTemp = decodeTemp.replace('%EmpEmployerPhone (Client)%', rec.EmpEmployerPhone);
                        decodeTemp = decodeTemp.replace('%EmpContactPerson (Client)%', rec.EmpContactPerson);
                        decodeTemp = decodeTemp.replace('%EmpWorkAddress (Client)%', rec.EmpWorkAddress);
                        decodeTemp = decodeTemp.replace('%comesfrom (Client)%', rec.comesfrom);
                        //Loan Fileds
                        decodeTemp = decodeTemp.replace('%LoanID (Loan)%', rec.LoanID);
                        decodeTemp = decodeTemp.replace('%LoanNumber (Loan)%', rec.LoanNumber);
                        decodeTemp = decodeTemp.replace('%PaymentPeriod (Loan)%', rec.PaymentPeriod);
                        decodeTemp = decodeTemp.replace('%DrawDownDate (Loan)%', rec.DrawDownDate);
                        decodeTemp = decodeTemp.replace('%LoanStatusID (Loan)%', rec.LoanStatusID);
                        decodeTemp = decodeTemp.replace('%LoanTerm (Loan)%', rec.LoanTerm);
                        decodeTemp = decodeTemp.replace('%FirstPaymentDue (Loan)%', rec.FirstPaymentDue);
                        decodeTemp = decodeTemp.replace('%LowerRate (Loan)%', rec.LowerRate);
                        decodeTemp = decodeTemp.replace('%HigherRate (Loan)%', rec.HigherRate);
                        decodeTemp = decodeTemp.replace('%InterestMethod (Loan)%', rec.InterestMethod);
                        decodeTemp = decodeTemp.replace('%app_id (Loan)%', rec.app_id);
                        decodeTemp = decodeTemp.replace('%Lender (Loan)%', rec.Lender);
                        decodeTemp = decodeTemp.replace('%Product (Loan)%', rec.Product);
                        decodeTemp = decodeTemp.replace('%Type (Loan)%', rec.Type);
                        decodeTemp = decodeTemp.replace('%Purpose (Loan)%', rec.Purpose);
                        decodeTemp = decodeTemp.replace('%LoanAmount (Loan)%', rec.LoanAmount);
                        decodeTemp = decodeTemp.replace('%DishonorFee (Loan)%', rec.DishonorFee);
                        decodeTemp = decodeTemp.replace('%Memo (Loan)%', rec.Memo);
                        decodeTemp = decodeTemp.replace('%NewDDRDate (Loan)%', rec.NewDDRDate);
                        decodeTemp = decodeTemp.replace('%BankAccDate (Loan)%', rec.BankAccDate);
                        decodeTemp = decodeTemp.replace('%PaymentSchDate (Loan)%', rec.PaymentSchDate);
                        decodeTemp = decodeTemp.replace('%EffectiveDate (Loan)%', rec.EffectiveDate);
                        decodeTemp = decodeTemp.replace('%DefaultNotice (Loan)%', rec.DefaultNotice);
                        decodeTemp = decodeTemp.replace('%DoubleChecked (Loan)%', rec.DoubleChecked);
                        decodeTemp = decodeTemp.replace('%CreateDate (Loan)%', rec.CreateDate);
                        decodeTemp = decodeTemp.replace('%EditDate (Loan)%', rec.EditDate);
                        decodeTemp = decodeTemp.replace('%LastResult (Loan)%', rec.LastResult);
                        decodeTemp = decodeTemp.replace('%EzidebitRefNo (Loan)%', rec.EzidebitRefNo);
                        decodeTemp = decodeTemp.replace('%OperatorName%', document.getElementById('hdnDualOpr').value);
                        tinymce.get('txtmailmessage').setContent(decodeTemp);
                        // $('#txtMailMessagse').val(EMAILTemplateFormat);
                    });
                }
            });
        }


        function limitText() {
            var limitField = $('#txtsmsdescriptiondual').val();
            var limitCount = $('#lblCountDowns').text();
            var limitNum = 159;

            if (Number(limitField.length) > Number(limitNum)) {
                $('#divMaxLimits').show();
                $('#divLeftCharacters').hide();
            }
            else {
                $('#divMaxLimits').hide();
                $('#divLeftCharacters').show();

                var temp = Number(limitNum) - Number(limitField.length);
                $('#lblCountDowns').html(temp);

                if (temp == 0) {
                    $('#divMaxLimits').show();
                    $('#divLeftCharacters').hide();
                }
            }
        }

        function showContactDataSms(SMSTemplateFormat) {
            $.ajax({
                url: "/WebServices/ApplicationContact.ashx?method=ApplicationContactSelect",
                contentType: "application/json; charset=utf-8",
                data: { 'ContactID': getQuerystring('contact_id', '') },
                success: function (data) {
                    $.each(eval(data.replace(/[\r\n]/, '')), function (i, rec) {

                        //ClientFileds
                        SMSTemplateFormat = SMSTemplateFormat.replace('%ContactID (Client)%', rec.ContactID);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%FirstName (Client)%', rec.FirstName);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%MiddleName (Client)%', rec.MiddleName);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%SurName (Client)%', rec.SurName);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Title (Client)%', rec.Title);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Mobile (Client)%', rec.Mobile);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%HomePhone (Client)%', rec.HomePhone);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Email (Client)%', rec.Email);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%DriverLicense (Client)%', rec.DriverLicense);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Citizenship (Client)%', rec.Citizenship);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%DateBirth (Client)%', rec.DateBirth);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Street (Client)%', rec.Street);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Suburb (Client)%', rec.Suburb);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%State (Client)%', rec.State);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%PostCode (Client)%', rec.PostCode);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%ResidencePeriod (Client)%', rec.ResidencePeriod);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%ResidenceLength (Client)%', rec.ResidenceLength);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Dependant (Client)%', rec.Dependant);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%app_ResidentialStatus (Client)%', rec.app_ResidentialStatus);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%app_number (Client)%', rec.app_number);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%app_id (Client)%', rec.app_id);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%NumberFromAppinfo (Client)%', rec.NumberFromAppinfo);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Memo (Client)%', rec.Memo);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%CreateDate (Client)%', rec.CreateDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EditDate (Client)%', rec.EditDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%DupwithContact (Client)%', rec.DupwithContact);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%deletedFlag (Client)%', rec.deletedFlag);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Role (Client)%', rec.Role);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Relationship (Client)%', rec.Relationship);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%WorkPhone (Client)%', rec.WorkPhone);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%FaxNumber (Client)%', rec.FaxNumber);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%secondEmailAddress (Client)%', rec.secondEmailAddress);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%PostalAddress (Client)%', rec.PostalAddress);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%IncomeType (Client)%', rec.IncomeType);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%SelfEmpTypeofEntity (Client)%', rec.SelfEmpTypeofEntity);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%SelfEmpBusinessName (Client)%', rec.SelfEmpBusinessName);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%SelfEmpABN (Client)%', rec.SelfEmpABN);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%SelfEmpNatureofBusiness (Client)%', rec.SelfEmpNatureofBusiness);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%SelfEmpPhone (Client)%', rec.SelfEmpPhone);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%SelfEmpAddress (Client)%', rec.SelfEmpAddress);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%KinsName (Client)%', rec.KinsName);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%KinsRelationship (Client)%', rec.KinsRelationship);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%KinsContactNumber (Client)%', rec.KinsContactNumber);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Notes (Client)%', rec.Notes);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EmpEmployer (Client)%', rec.EmpEmployer);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EmpOccupation (Client)%', rec.EmpOccupation);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EmpJobPosition (Client)%', rec.EmpJobPosition);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EmpEmployerPhone (Client)%', rec.EmpEmployerPhone);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EmpContactPerson (Client)%', rec.EmpContactPerson);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EmpWorkAddress (Client)%', rec.EmpWorkAddress);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%comesfrom (Client)%', rec.comesfrom);
                        //LoanFileds
                        SMSTemplateFormat = SMSTemplateFormat.replace('%LoanID (Loan)%', rec.LoanID);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%LoanNumber (Loan)%', rec.LoanNumber);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%PaymentPeriod (Loan)%', rec.PaymentPeriod);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%DrawDownDate (Loan)%', rec.DrawDownDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%LoanStatusID (Loan)%', rec.LoanStatusID);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%LoanTerm (Loan)%', rec.LoanTerm);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%FirstPaymentDue (Loan)%', rec.FirstPaymentDue);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%LowerRate (Loan)%', rec.LowerRate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%HigherRate (Loan)%', rec.HigherRate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%InterestMethod (Loan)%', rec.InterestMethod);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%app_id (Loan)%', rec.app_id);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Lender (Loan)%', rec.Lender);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Product (Loan)%', rec.Product);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Type (Loan)%', rec.Type);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Purpose (Loan)%', rec.Purpose);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%LoanAmount (Loan)%', rec.LoanAmount);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%DishonorFee (Loan)%', rec.DishonorFee);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Memo (Loan)%', rec.Memo);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%NewDDRDate (Loan)%', rec.NewDDRDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%BankAccDate (Loan)%', rec.BankAccDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%PaymentSchDate (Loan)%', rec.PaymentSchDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EffectiveDate (Loan)%', rec.EffectiveDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%DefaultNotice (Loan)%', rec.DefaultNotice);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%DoubleChecked (Loan)%', rec.DoubleChecked);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%CreateDate (Loan)%', rec.CreateDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EditDate (Loan)%', rec.EditDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%LastResult (Loan)%', rec.LastResult);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EzidebitRefNo (Loan)%', rec.EzidebitRefNo);
                        $('#txtsmsdescriptiondual').val(SMSTemplateFormat);
                        if (SMSTemplateFormat != "") {
                            $('#txtsmsdescriptiondual').validatebox({
                                required: false,

                            });
                        }
                    });
                }
            });
        }

        function chkValue() {
            $('#txtsmsdescriptiondual').validatebox({
                required: true,

            });
        }

        function showApplicationDataSms(SMSTemplateFormat) {
            $.ajax({
                url: "/WebServices/ApplicationInfo.ashx?method=BindApplicationForSMSFields",
                contentType: "application/json; charset=utf-8",
                data: { 'app_id': getQuerystring('app_id', '') },
                success: function (data) {
                    $.each(eval(data.replace(/[\r\n]/, '')), function (i, rec) {

                        //ApplicationFileds
                        SMSTemplateFormat = SMSTemplateFormat.replace('%app_id (Application)%', rec.app_id);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%deletedFlag (Application)%', rec.deletedFlag);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%app_result (Application)%', rec.app_result);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%ResultID (Application)%', rec.ResultID);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%LoadNo (Application)%', rec.LoadNo);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Folder (Application)%', rec.Folder);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%AwaitDocs (Application)%', rec.AwaitDocs);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%NoInApplication (Application)%', rec.NoInApplication);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%OfferedAmount (Application)%', rec.OfferedAmount);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%DesiredAmount (Application)%', rec.DesiredAmount);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%amountMoto (Application)%', rec.amountMoto);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%amoutProperties (Application)%', rec.amoutProperties);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%TextAwaitDoc (Application)%', rec.TextAwaitDoc);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%PurposeSummary (Application)%', rec.PurposeSummary);
                        // SMSTemplateFormat = SMSTemplateFormat.replace('%Unsubscribe_Ad (Application)%', rec.Unsubscribe_Ad);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Memo (Application)%', rec.Memo);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%LenderID (Application)%', rec.LenderID);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%OutSrcLenderVal (Application)%', rec.OutSrcLenderVal);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%ReferrerID (Application)%', rec.ReferrerID);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%ReferrerVal (Application)%', rec.ReferrerVal);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%CreatedDate (Application)%', rec.CreatedDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EditDate (Application)%', rec.EditDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%comesfrom (Application)%', rec.comesfrom);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%securities (Application)%', rec.securities);
                        //ClientFileds
                        SMSTemplateFormat = SMSTemplateFormat.replace('%ContactID (Client)%', rec.ContactID);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%FirstName (Client)%', rec.FirstName);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%MiddleName (Client)%', rec.MiddleName);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%SurName (Client)%', rec.SurName);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Title (Client)%', rec.Title);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Mobile (Client)%', rec.Mobile);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%HomePhone (Client)%', rec.HomePhone);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Email (Client)%', rec.Email);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%DriverLicense (Client)%', rec.DriverLicense);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Citizenship (Client)%', rec.Citizenship);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%DateBirth (Client)%', rec.DateBirth);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Street (Client)%', rec.Street);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Suburb (Client)%', rec.Suburb);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%State (Client)%', rec.State);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%PostCode (Client)%', rec.PostCode);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%ResidencePeriod (Client)%', rec.ResidencePeriod);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%ResidenceLength (Client)%', rec.ResidenceLength);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Dependant (Client)%', rec.Dependant);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%app_ResidentialStatus (Client)%', rec.app_ResidentialStatus);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%app_number (Client)%', rec.app_number);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%app_id (Client)%', rec.app_id);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%NumberFromAppinfo (Client)%', rec.NumberFromAppinfo);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Memo (Client)%', rec.Memo);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%CreateDate (Client)%', rec.CreateDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EditDate (Client)%', rec.EditDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%DupwithContact (Client)%', rec.DupwithContact);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%deletedFlag (Client)%', rec.deletedFlag);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Role (Client)%', rec.Role);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Relationship (Client)%', rec.Relationship);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%WorkPhone (Client)%', rec.WorkPhone);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%FaxNumber (Client)%', rec.FaxNumber);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%secondEmailAddress (Client)%', rec.secondEmailAddress);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%PostalAddress (Client)%', rec.PostalAddress);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%IncomeType (Client)%', rec.IncomeType);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%SelfEmpTypeofEntity (Client)%', rec.SelfEmpTypeofEntity);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%SelfEmpBusinessName (Client)%', rec.SelfEmpBusinessName);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%SelfEmpABN (Client)%', rec.SelfEmpABN);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%SelfEmpNatureofBusiness (Client)%', rec.SelfEmpNatureofBusiness);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%SelfEmpPhone (Client)%', rec.SelfEmpPhone);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%SelfEmpAddress (Client)%', rec.SelfEmpAddress);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%KinsName (Client)%', rec.KinsName);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%KinsRelationship (Client)%', rec.KinsRelationship);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%KinsContactNumber (Client)%', rec.KinsContactNumber);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Notes (Client)%', rec.Notes);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EmpEmployer (Client)%', rec.EmpEmployer);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EmpOccupation (Client)%', rec.EmpOccupation);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EmpJobPosition (Client)%', rec.EmpJobPosition);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EmpEmployerPhone (Client)%', rec.EmpEmployerPhone);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EmpContactPerson (Client)%', rec.EmpContactPerson);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EmpWorkAddress (Client)%', rec.EmpWorkAddress);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%comesfrom (Client)%', rec.comesfrom);
                        //LoanFileds
                        SMSTemplateFormat = SMSTemplateFormat.replace('%LoanID (Loan)%', rec.LoanID);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%LoanNumber (Loan)%', rec.LoanNumber);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%PaymentPeriod (Loan)%', rec.PaymentPeriod);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%DrawDownDate (Loan)%', rec.DrawDownDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%LoanStatusID (Loan)%', rec.LoanStatusID);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%LoanTerm (Loan)%', rec.LoanTerm);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%FirstPaymentDue (Loan)%', rec.FirstPaymentDue);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%LowerRate (Loan)%', rec.LowerRate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%HigherRate (Loan)%', rec.HigherRate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%InterestMethod (Loan)%', rec.InterestMethod);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%app_id (Loan)%', rec.app_id);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Lender (Loan)%', rec.Lender);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Product (Loan)%', rec.Product);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Type (Loan)%', rec.Type);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Purpose (Loan)%', rec.Purpose);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%LoanAmount (Loan)%', rec.LoanAmount);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%DishonorFee (Loan)%', rec.DishonorFee);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%Memo (Loan)%', rec.Memo);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%NewDDRDate (Loan)%', rec.NewDDRDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%BankAccDate (Loan)%', rec.BankAccDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%PaymentSchDate (Loan)%', rec.PaymentSchDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EffectiveDate (Loan)%', rec.EffectiveDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%DefaultNotice (Loan)%', rec.DefaultNotice);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%DoubleChecked (Loan)%', rec.DoubleChecked);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%CreateDate (Loan)%', rec.CreateDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EditDate (Loan)%', rec.EditDate);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%LastResult (Loan)%', rec.LastResult);
                        SMSTemplateFormat = SMSTemplateFormat.replace('%EzidebitRefNo (Loan)%', rec.EzidebitRefNo);
                        $('#txtsmsdescriptiondual').val(SMSTemplateFormat);
                        if (SMSTemplateFormat != "") {
                            $('#txtsmsdescriptiondual').validatebox({
                                required: false,

                            });
                        }
                    });
                }
            });
        }
    </script>

</body>
</html>
